﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ page contentType="text/html; charset=utf-8"%>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
    
     <script src="${pageContext.request.contextPath }/scripts/boot.js" type="text/javascript"></script>
    

    <style type="text/css">
    html, body
    {
        font-size:12px;
        padding:0;
        margin:0;
        border:0;
        height:100%;
        overflow:hidden;
    }
    </style>
</head>
<body>    
    
<fieldset style="border:solid 1px #aaa;padding:3px;">
            <legend >基本信息</legend> 
    <form id="form1" method="post">
        <input name="id" class="mini-hidden" />
        <div style="padding-left:11px;padding-bottom:5px;">
            <table style="table-layout:fixed;" >
              
      
              
<tr>
<td style="width:12%;text-align:right;white-space:nowrap;"><span style="color:red;" >*&nbsp;&nbsp;</span>单位名称：</td>
<td style="width:22%;"><input name="aab004" id="unit_name" style="width:80%;" maxlength="100" onvalidation="checkName" class="mini-textbox" required="true"   emptyText="请输入单位名称"/></td>
<td style="width:12%;text-align:right;"><span style="color:red;" >*&nbsp;&nbsp;</span>单位性质：</td>
<td style="width:22%;"><input name="aab019" class="mini-textbox sasLabel"  borderStyle="border:0" style="width:80%;" value="个体工商户"  allowInput="false" /></td>
<td style="width:12%;text-align:right;">统一社会信用代码：</td>
<td style="width:22%;"><input name="aab131" style="width:80%;"  class="mini-textbox" id="credit_id" onvalidation="CheckNumber"  maxlength="18" emptyText="请输入信用代码 18位" /></td>
</tr>
<tr>
<td style="width:12%;text-align:right;">组织机构代码：</td>
<td style="width:22%;"><input name="aab003" style="width:80%;" class="mini-textbox"  id="organization_id" onvalidation="CheckNumber1" maxlength="10"  emptyText="请输入组织机构代码"/></td>
<td style="width:12%;text-align:right;">地税登记证号：</td>
<td style="width:22%;"><input name="aab030" style="width:80%;" class="mini-textbox"   maxlength="40" emptyText="请输入税号"/></td>
<td style="width:12%;text-align:right;"><span style="color:red;" >*&nbsp;&nbsp;</span>联系人：</td>
<td style="width:22%;"><input name="aae004" style="width:80%;" class="mini-textbox"  maxlength="50" required="true"   emptyText="请输入联系人"/></td>
</tr>
<tr>
<td style="width:12%;text-align:right;"><span style="color:red;" >*&nbsp;&nbsp;</span>联系电话：</td>
<td style="width:22%;"><input name="aae005" style="width:80%;" class="mini-textbox" required="true"  vtype="int" maxlength="50" emptyText="请输入联系电话"/></td>
<td style="width:12%;text-align:right;"><span style="color:red;" >*&nbsp;&nbsp;</span>法定代表人姓名：</td>
<td style="width:22%;"><input name="aab013" style="width:80%;" class="mini-textbox" required="true" maxlength="50"  emptyText="请输入法定代表人姓名"/></td>
<td style="width:12%;text-align:right;white-space:nowrap;"><span style="color:red;" >*&nbsp;&nbsp;</span>法定代表人证件类型：</td>
<td style="width:22%;"><input name="aac058" id="type" style="width:80%;" class="mini-combobox" valueField="bm" textField="mch" 
	url="${pageContext.request.contextPath }/cs_ounit.do?method=getselect&lx=sfzjlx"
 required="true"   emptyText="请输入法定代表人证件类型"/></td>
</tr>
<tr>
<td style="width:12%;text-align:right;white-space:nowrap"><span style="color:red;" >*&nbsp;&nbsp;</span>法定代表人/负责人证件号码：</td>
<td style="width:22%;"><input name="aab014" style="width:80%;"  class="mini-textbox" style="width:50%;" vtype="maxLength:18" required="true" onvalidation="onNumber"  emptyText="请输入法定代表人证件号码"/></td>
<td style="width:12%;text-align:right;white-space:nowrap;"><span style="color:red;" >*&nbsp;&nbsp;</span>法定代表人联系电话：</td>
<td style="width:22%;"><input name="bae182" style="width:80%;" class="mini-textbox"  vtype="int" vtype="maxLength:50" required="true" emptyText="请输入法定代表人联系电话"/></td>
</tr>


<%-- <tr>
<td style="width:12%;text-align:right;">注册区划：</td>
<td style="width:22%;"><input name="aab078"  id="aab078" style="width:80%;" class="mini-combobox" valueField="bm" textField="mch" 
                           url="${pageContext.request.contextPath }/cs_ounit.do?method=getselect&lx=xzqh"  onvaluechanged="onDeptChanged"  emptyText="请输入注册区划"/></td>
 </tr>
 <tr>
<td style="width:12%;text-align:right;">注册街道：</td>
<td style="width:22%;"><input name="aab073" id="aab073" style="width:80%;" class="mini-combobox" onvaluechanged="onDeptChanged2" valueField="id" textField="name"  nullItemText="请选择..." emptyText="请选择注册街道"/></td>
<td style="width:12%;text-align:right;">注册社区：</td>
<td style="width:22%;"><input name="aab074" id="aab074" style="width:80%;" class="mini-combobox" valueField="id" textField="name"	  nullItemText="请选择..." emptyText="请选择注册社区"   /></td>
<td style="width:12%;text-align:right;">注册地址：</td>
<td style="width:22%;"><input name="aab156" style="width:80%;" class="mini-textbox" vtype="maxLength:50"    emptyText="请输入注册地址"/></td>
</tr>
<tr>
<td style="width:12%;text-align:right;white-space:nowrap;">经营/办公地区划：</td>
<td style="width:22%;"><input name="aab077" id="aab077" style="width:80%;" class="mini-combobox" valueField="bm" textField="mch" 
                            url="${pageContext.request.contextPath }/cs_ounit.do?method=getselect&lx=xzqh"  onvaluechanged="onDeptChanged3"  emptyText="请输入经营/办公地区划"/></td>
<td style="width:12%;text-align:right;white-space:nowrap;">经营/办公地街道：</td>
<td style="width:22%;"><input name="aab081" id="aab081" style="width:80%;" class="mini-combobox" onvaluechanged="onDeptChanged4" valueField="id" textField="name"  nullItemText="请选择..."    emptyText="请输入经营/办公地街道"/></td>
<td style="width:12%;text-align:right;white-space:nowrap;">经营/办公地社区：</td>
<td style="width:22%;"><input name="aab082" id="aab082" style="width:80%;" class="mini-combobox" valueField="id" textField="name"	  nullItemText="请选择..." emptyText="请选择经营/办公社区" /></td>
</tr>
<tr>
<td style="width:12%;text-align:right;white-space:nowrap;">经营/办公地址：</td>
<td style="width:22%;"><input name="aab157" style="width:80%;" class="mini-textbox" vtype="maxLength:50"    emptyText="请输入经营/办公地址"/></td>
<td style="width:12%;text-align:right;white-space:nowrap;">批准文号：</td>
<td style="width:22%;"><input name="aae051" style="width:80%;" class="mini-textbox"  vtype="maxLength:50"  emptyText="请输入批准文号"/></td>
<td style="width:12%;text-align:right;white-space:nowrap;">批准单位/注册登记机关：</td>
<td style="width:22%;"><input name="aae048" style="width:80%;" class="mini-textbox" 
           vtype="maxLength:50"                   emptyText="请输入批准单位/注册登记机关"/></td>
</tr>
<tr>
<td style="width:12%;text-align:right;white-space:nowrap;">批准日期/成立日期：</td>
<td style="width:22%;"><input name="aae049" style="width:80%;" class="mini-datepicker" vtype="maxLength:50" vtype="date:yyyy-MM-dd"  ondrawdate="onDrawDate" emptyText="请输入批准日期/成立日期"/></td>
<td style="width:12%;text-align:right;white-space:nowrap;">行业风险类别：</td>
<td style="width:22%;"><input name="aaa149"  style="width:80%;" class="mini-combobox" valueField="bm" textField="mch" 
	url="${pageContext.request.contextPath }/cs_ounit.do?method=getselect&lx=hyfxlb"
    emptyText="请选择行业风险类别"/></td>
 <td style="width:12%;text-align:right;white-space:nowrap;">邮编：</td>
<td style="width:22%;"><input name="aac047" style="width:80%;" class="mini-textbox"  vtype="maxLength:50"  emptyText="请输入邮编"/></td>
</tr>
<tr>
<td style="width:12%;text-align:right;white-space:nowrap;">工商营业执照种类：</td>
<td style="width:22%;"><input name="aab006"  style="width:80%;" class="mini-combobox" valueField="bm" textField="mch" 
	url="${pageContext.request.contextPath }/cs_ounit.do?method=getselect&lx=yyzz"
    emptyText="请选择工商营业执照种类"/></td>
<td style="width:12%;text-align:right;white-space:nowrap;">工商营业执照号码：</td>
<td style="width:22%;"><input name="aab007" style="width:80%;" class="mini-textbox"   vtype="int" vtype="maxLength:11" emptyText="请输入工商营业执照号码"/></td>
<td style="width:12%;text-align:right;white-space:nowrap;">工商营业发照日期：</td>
<td style="width:22%;"><input name="aab008" style="width:80%;" class="mini-datepicker"  vtype="maxLength:50" vtype="date:yyyy-MM-dd" emptyText="请选择日期"/></td>
</tr>
<tr>
<td style="width:12%;text-align:right;white-space:nowrap;">工商营业执照有效期限：</td>
<td style="width:22%;"><input name="aab009" style="width:80%;" class="mini-textbox"   vtype="int" vtype="maxLength:11" emptyText="请输入有效期限"/></td>
<td style="width:12%;text-align:right;white-space:nowrap;">隶属关系：</td>
<td style="width:22%;"><input name="aab021"  style="width:80%;" class="mini-combobox" valueField="bm" textField="mch" 
	url="${pageContext.request.contextPath }/cs_ounit.do?method=getselect&lx=lsgx"
    emptyText="请选择隶属关系"/></td>
</tr>

<tr>
<td style="width:12%;text-align:right;">国民经济行业：</td>
<td style="width:22%;"><input name="gmjjhy" style="width:80%;" class="mini-textbox"   vtype="maxLength:50" emptyText="请输入国民经济行业"/></td>
<td style="width:12%;text-align:right;">工商营业执照注册机关：</td>
<td style="width:22%;"><input name="aab202" style="width:80%;" class="mini-textbox"   vtype="maxLength:50" emptyText="请输入注册机关"/></td>
<td style="width:12%;text-align:right;">经济类型：</td>
<td style="width:22%;"><input name="aab020" style="width:80%;" class="mini-textbox"  vtype="maxLength:50"    emptyText="请输入经济类型"/></td>
</tr>
<tr>
<td style="width:12%;text-align:right;">主管部门或总机构：</td>
<td style="width:22%;"><input name="aab023" style="width:80%;" class="mini-textbox"   vtype="maxLength:50" emptyText="请输入主管部门或机构"/></td>
<td style="width:12%;text-align:right;">注册资金：</td>
<td style="width:22%;"><input name="cba001" style="width:80%;" class="mini-textbox"   vtype="maxLength:50" emptyText="请输入注册资金"/></td>
<td style="width:12%;text-align:right;"><span style="color:red;" >*&nbsp;&nbsp;</span>是否派遣：</td>
<td style="width:22%;"><input name="aae901" style="width:80%;" class="mini-combobox" valueField="bm" textField="mch" 
	url="${pageContext.request.contextPath }/cs_ounit.do?method=getselect&lx=pq" vtype="maxLength:50" required="true"   emptyText="请选择是否派遣"/></td>
</tr>
<tr>
<td style="width:12%;text-align:right;">单位规模：</td>
<td style="width:22%;"><input name="dwgm" style="width:80%;" class="mini-textbox"   vtype="maxLength:50" emptyText="请输入单位规模"/></td>
<td style="width:12%;text-align:right;"><span style="color:red;" >*&nbsp;&nbsp;</span>单位监管状态：</td>
<td style="width:22%;"><input name="aae902" style="width:80%;" class="mini-combobox" valueField="bm" textField="mch" 
	url="${pageContext.request.contextPath }/cs_ounit.do?method=getselect&lx=jgzt" value="01"  vtype="maxLength:50" emptyText="请选择单位监管状态"/></td>
<td style="width:12%;text-align:right;">单位注销日期：</td>
<td style="width:22%;"><input name="dwzxrq" style="width:80%;" class="mini-datepicker"  vtype="maxLength:50"    emptyText="请输入注销日期"/></td>
</tr> --%>

            </table>
        </div>
       
        <div style="text-align:center;padding:10px;">     
        	<a class="mini-button" onclick="onOk" iconCls="icon-ok" style="width:60px;margin-right:20px;">确定</a>           
           <a class="mini-button" onclick="onReset" iconCls="icon-remove" style="width:60px;margin-right:20px;">重置</a>      
           <!--  <a class="mini-button" onclick="onCancel" style="width:60px;">取消</a> -->       
        </div>        
    </form>
	</fieldset>
    <script type="text/javascript">
        mini.parse();
		var judge=true;
		var judge2=true;
        var form = new mini.Form("form1");
		
        function SaveData() {
            var o = form.getData();
            form.validate();
            if (form.isValid() == false) return;
            var json = mini.encode([o]);
            
            $.ajax({
                url: "/zyk/cs_ounit.do?method=savecs_ounit",
				type: 'post',
                data: { data: json},
                cache: false,
                success: function (text) {
                   // CloseWindow("save");
                    mini.alert("数据登记成功！社会保障卡号为"+text);
                    form.clear();
                    mini.getbyName("aab019").setValue("个体工商户");
                     CloseWindow("save");
                    return;
                },
                error: function (jqXHR, textStatus, errorThrown) {
                    alert(jqXHR.responseText);
                    CloseWindow();
                }
            });
        }


	
         function CloseWindow(action) {            
            if (action == "close" && form.isChanged()) {
                if (confirm("数据被修改了，是否先保存？")) {
                    return false;
                }
            }
             if (window.CloseOwnerWindow) return window.CloseOwnerWindow(action);
            else window.close();            
        }
        
        function onOk(e) {
     //    checkSame();
         if(judge&judge2){
          SaveData();
          
          window.close();
         
         }
/*           if(!judge2){
          var credit_id = mini.get("#credit_id").getValue();
          var organization_id = mini.get("#organization_id").getValue();
 			if(credit_id!="" && organization_id!="" ){
       			alert("信用编码和组织机构代码不能同时输入！");
       				judge2=false;
  			 }
  			  if(credit_id==""&&organization_id==""){
  			 	alert("信用编码和组织机构代码不能同时为空！");
  			 judge2=false;
  			  window.close();
  			 }
        } */
        }
        
        function onReset(e) {
            form.clear();
            mini.getbyName("aab019").setValue("个体工商户");
        }

        function GetData() {
            var o = form.getData();
            return o;
        }
       
       
        function onCancel(e) {
            CloseWindow("cancel");
        }


	 function onDeptChanged(e) {
            var deptCombo = mini.getbyName("dept_id");
            var positionCombo = mini.getbyName("position");
            var dept_id = deptCombo.getValue();

            positionCombo.load("../data/AjaxService.jsp?method=GetPositionsByDepartmenId&id=" + dept_id);
            positionCombo.setValue("");
        }

	////////////
	 function onNumber(e){
		var zjlx=mini.get("#type").getValue();
		if(zjlx == '01'){
			if(e.isValid){
			
				if(isNumber(e.value) == false){
					e.errorText = "身份证输入不合法";
					e.isValid = false;
					
					//mini.alert(e.errorText);
				}
			}
		}
	}	
	
	function isNumber(v){
        var tel = /^\d{6}(18|19|20)?\d{2}(0[1-9]|1[12])(0[1-9]|[12]\d|3[01])\d{3}(\d|X)$/i;
        var flag = true;
        if(!tel.test(v)){
            flag = false;
        }else{
            var arrInt = new Array(7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2);
            var arrCh = new Array('1', '0', 'X', '9', '8', '7', '6', '5', '4', '3', '2');
            var nTemp = 0, i;
            var temp = v.substring(0,17);
            for (i = 0; i < temp.length; i++) {
                 nTemp += temp.substr(i, 1) * arrInt[i];
                }
                temp += arrCh[nTemp % 11];
            if(temp != v) {
               flag = false;
            }
        }
          return flag;
    }

	 function SetData(data) {
            if (data.action == "edit") {
                //跨页面传递的数据对象，克隆后才可以安全使用
                data = mini.clone(data);
               
                $.ajax({
                    url: "/zyk/cs_ounit.do?method=getcs_ounitdata&id=" + data.id,
                    cache: false,
                    success: function (text) {
                        var o = mini.decode(text);
                        form.setData(o);
                        form.setChanged(false);
                        //onDeptChanged();
                        //mini.getbyName("position").setValue(o.position);
                    }
                });
                }
                }
            
function checkName(){
     var name = mini.getbyName("aab004").getValue().trim();
  //   var id = mini.get("id").getValue();
	 $.ajax({
           	 url: "/zyk/cs_ounit.do?method=getunitname",
             dataType : 'JSON',
	 		 data : {name:name},
             success: function(result) {
                   
			//已经存在该名字提示用户
				if(result != null)
				{  /*
					if(id==result.id){
						judge=true;
					}
					else{
					*/
					mini.get("#unit_name").setValue();  
					mini.alert("该单位已注册，请重新输入");
					
					//form.clear();
					judge=false;
				//}
				}
				else{
					judge=true;
					}
					}
				
               });
               }

/* function checkSame()
{
    var credit_id = mini.get("#credit_id").getValue().trim();
        var organization_id = mini.get("#organization_id").getValue().trim();
    if(credit_id!="" && organization_id!="" ){
       mini.alert("信用编码和组织机构代码不能同时输入！");
       judge2=false;
   }
   else if(credit_id==""&&organization_id==""){
       mini.alert("信用编码和组织机构代码不能同时为空！");
       judge2=false;
   }else{
   	 judge2=true;
   }
} */

function CheckNumber(e){
          var aab131 = mini.getbyName("aab131").getValue().trim();
          
          if(aab131.length<18&aab131.length>=1){
            e.errorText = "统一社会信用代码必须为18位";
            e.isValid = false;
            judge=false;
          }
          else{
          judge=true;
          }
        }
function CheckNumber1(e){
          var aab003 = mini.getbyName("aab003").getValue().trim();
          var a= mini.getbyName("aab003").getValue().trim().substring(8,9);
          if(aab003.length<10&aab003.length>=1){
            e.errorText = "组织机构代码必须为10位";
            e.isValid = false;
            judge=false;
          }else if(a!="-"){
          	e.errorText = "倒数第二位必须是半角中划线 ”-“ ";
            e.isValid = false;
            judge=false;
          }
          
          else{
          judge=true;
          }
        }

function onDrawDate(e) {
            var date = e.date;
            var d = new Date();

            if (date.getTime() > d.getTime()) {
                e.allowSelect = false;
            }
        }

 function onDeptChanged() {
    var aab078 = mini.get("#aab078").getValue();
    var aab073 = mini.get("aab073"); 
    aab073.setValue("");
    var url = "${pageContext.request.contextPath }/unit.do?method=getselect1&dept_id="+aab078;
    aab073.setUrl(url);
    aab073.select(0);
    onDeptChanged2();
   } 
   function onDeptChanged2() {
    var aab073 = mini.get("#aab073").getValue();
    var aab074 = mini.get("aab074");
    aab074.setValue("");
    var url= "${pageContext.request.contextPath }/unit.do?method=getselect2&dept_id="+aab073;
    aab074.setUrl(url);
    aab074.select(0);
   }
   function onDeptChanged3() {
    var aab077 = mini.get("#aab077").getValue();
    var aab081 = mini.get("aab081");
    aab081.setValue("");
    var url= "${pageContext.request.contextPath }/unit.do?method=getselect1&dept_id="+aab077;
    aab081.setUrl(url);
    aab081.select(0);
    onDeptChanged4();
   } 
   function onDeptChanged4() {
    var aab081 = mini.get("#aab081").getValue();
    var aab082 = mini.get("aab082");
    aab082.setValue("");
    var url= "${pageContext.request.contextPath }/unit.do?method=getselect2&dept_id="+aab081;
    aab082.setUrl(url);
    aab082.select(0);
   }  
        
        
    </script>
</body>
</html>